# -*- coding: utf-8 -*-
from main.support import get_common_info
import settings
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from main.forms import ExtendedRegistrationFormUniqueEmail
from django.contrib import admin
admin.autodiscover()


urlpatterns = patterns('',
     url('accounts/register/$', 'registration.views.register', {'form_class': ExtendedRegistrationFormUniqueEmail, 'backend': 'email-registration.ExtendedRegistrationBackEnd'}, name='registration_register'),
     url('accounts/password/reset/$', 'django.contrib.auth.views.password_reset', {'template_name': 'registration/password_recovery_1.html'}, name='auth_password_reset'),
     url('accounts/password/reset/done/$', 'django.contrib.auth.views.password_reset_done', {'template_name': 'registration/password_recovery_2.html'}, name='auth_password_reset_done'),
     url('accounts/password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', {'template_name': 'registration/password_recovery_confirm.html'}, name='auth_password_recovery_confirm'),
     url('accounts/password/reset/complete/$','django.contrib.auth.views.password_reset_complete', {'template_name': 'registration/password_recovery_complete.html'}, name='auth_password_recovery_complete'),
     #url('accounts/activate/complete/$','django.contrib.auth.views.activate_complete', {'template_name': 'registration/password_recovery_complete.html'}, name='auth_password_recovery_complete'),
     (r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/media/images/favicon.gif'}),
     (r'accounts/', include('registration.urls')),
     (r'^userinfo/', 'main.views.add_userinfo'),
     (r'^admin/', include(admin.site.urls)),
     (r'^$', 'main.views.index' ),
     (r'^(\d+)/$', 'main.views.index' ),
     (r'^get_cities/$', 'main.support.get_cities' ),
     (r'^update_avatar/$','main.views.update_avatar'),
     (r'^profile/$', 'main.views.user_profile'),
     (r'^profile/(\d+)/$', 'main.views.user_profile'),
     (r'^settings/private/$', 'main.views.add_userinfo'),
     (r'^settings/main/$', 'main.views.main_settings'),
     (r'^settings/security/$', 'main.views.security_settings'),
     (r'^settings/notify/$', 'main.views.notify_settings'),
     (r'^change_email/$', 'main.views.change_email'),
     (r'^change_password/$', 'main.views.change_password'),

     (r'^users/$', 'main.views.users'),
     (r'^users/(\d+)/$', 'main.views.users'),
     (r'^online_friends/$', 'main.views.online_friends'),
     (r'^online_friends/(\d+)/$', 'main.views.online_friends'),
     (r'^online_users/$', 'main.views.online_users'),
     (r'^online_users/(\d+)/$', 'main.views.online_users'),
     (r'^possible_friends/$', 'main.views.possible_friends'),
     (r'^possible_friends/(\d+)/$', 'main.views.possible_friends'),
     (r'^friends/$', 'main.views.friends'),
     (r'^friends/(\d+)/$', 'main.views.friends'),
     (r'^friends/invite/(\d+)/$', 'friends.views.invite'),
     (r'^friends/accept/(\d+)/$', 'friends.views.accept'),
     (r'^friends/decline/(\d+)/$', 'friends.views.decline'),
     (r'^friends/cancel/(\d+)/$', 'friends.views.cancel'),
     (r'^dialog/(\w+)/$', 'main.views.dialog'),
     (r'^all_dialogs/$', 'main.views.all_dialogs'),
     #url(r'^inbox/$', inbox, {'template_name': 'my_inbox.html',}, name='messages_inbox'),
     (r'^messages/', include('messages.urls')),

     (r'^check_new_messages/(\d+)/(\d+)/$', 'main.views.check_new_messages'),
     (r'^post_message_ajax/$', 'main.views.post_message_ajax'),

     (r'^add_company/$', 'main.views.add_company'),
     (r'^edit_company/(\d+)/$', 'main.views.edit_company'),
     
     (r'^companies/$', 'main.views.companies'),
     (r'^companies/(\d+)/$', 'main.views.companies'),

     (r'^online_companies/$', 'main.views.companies_online'),
     (r'^online_companies/(\d+)/$', 'main.views.companies_online'),
     
     (r'^company/(\d+)/$', 'main.views.company'),
     (r'^add_to_companies/(\d+)/$', 'main.views.add_to_companies'),
     (r'^delete_from_company/(\d+)/$', 'main.views.delete_from_company'),
     (r'^add_partner/(\d+)/$', 'main.views.add_partner'),
     (r'^delete_partner/(\d+)/(\d+)/$', 'main.views.delete_partner'),
     (r'^user_companies/(\d+)/$', 'main.views.user_companies'),
     (r'^user_companies/(\d+)/(\d+)/$', 'main.views.user_companies'),
     (r'^by_category/(\d+)/$', 'main.views.by_category'),
     (r'^by_category/(\d+)/(\d+)/$', 'main.views.by_category'),

     (r'^post_wall_comment/$', 'main.views.post_wall_comment'),

     (r'^discussion/(\d+)/$', 'main.views.discussion'),
     (r'^discussions/$', 'main.views.discussions'),
     (r'^discussions/(\d+)/$', 'main.views.discussions'),

     (r'^start_discussion/$', 'main.views.start_discussion'),
     (r'^post_discussion_message/(\d+)/$', 'main.views.post_discussion_message'),

     (r'^all_clients/(\d+)/$', 'main.views.all_clients'),
     (r'^all_clients/(\d+)/(\d+)/$', 'main.views.all_clients'),

     (r'^all_partners/(\d+)/$', 'main.views.all_partners'),
     (r'^all_partners/(\d+)/(\d+)/$', 'main.views.all_partners'),

     (r'^showcase/(\d+)/$', 'main.views.showcase'),
     (r'^showcase/(\d+)/(\d+)/$', 'main.views.showcase'),

     (r'^add_good/(\d+)/$', 'main.views.add_good'),
     (r'^edit_good/(\d+)/$', 'main.views.edit_good'),

     (r'^offers/$', 'main.views.offers'),
     (r'^offers/(\d+)/$', 'main.views.offers'),

     (r'^all_offers/(\d+)/$', 'main.views.company_offers'),
     (r'^all_offers/(\d+)/(\d+)/$', 'main.views.company_offers'),

     (r'^create_offer/(\d+)/$', 'main.views.create_offer'),
     (r'^edit_offer/(\d+)/$', 'main.views.edit_offer'),
     (r'^delete_offer/(\d+)/$', 'main.views.delete_offer'),

     (r'^orders/$', 'main.views.orders'),
     (r'^orders/(\d+)/$', 'main.views.orders'),
     (r'^order/(\d+)/$', 'main.views.show_order'),
     (r'^add_order/$', 'main.views.create_order'),
     (r'^edit_order/(\d+)/$', 'main.views.edit_order'),
     (r'^response_to_order/(\d+)/$', 'main.views.response_to_order'),
     (r'^decline_executor/(\d+)/$', 'main.views.decline_executor'),
     (r'^accept_executor/(\d+)/$', 'main.views.accept_executor'),

     (r'^make_notify_settings/$', 'main.views.make_notify_settings'),
     (r'^support/$', 'main.views.support'),
     (r'^about/$', 'django.views.generic.simple.direct_to_template', {'template': 'about.html', 'extra_context': {'info': get_common_info() }}),
     (r'^rules/$', 'django.views.generic.simple.direct_to_template', {'template': 'rules.html', 'extra_context': {'info': get_common_info() }}),
     (r'^contacts/$', 'django.views.generic.simple.direct_to_template', {'template': 'contacts.html', 'extra_context': {'info': get_common_info() }}),
     (r'^search/$', 'main.views.search'),
     

)

if settings.DEBUG:
    urlpatterns += patterns('django.views.static',
                          (r'^media/(?P<path>.*)$',
                           'serve', {
                                     'document_root': settings.MEDIA_ROOT,
                                     'show_indexes': True }),
                          )
